package com.ruoyi.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.Jigouxinxi;
import com.ruoyi.system.service.IJigouxinxiService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 机构信息表Controller
 * 
 * @author ruoyi
 * @date 2023-12-04
 */
@RestController
@RequestMapping("/system/jigouxinxi")
public class JigouxinxiController extends BaseController
{
    @Autowired
    private IJigouxinxiService jigouxinxiService;

    /**
     * 查询机构信息表列表
     */
    @PreAuthorize("@ss.hasPermi('system:jigouxinxi:list')")
    @GetMapping("/list")
    public TableDataInfo list(Jigouxinxi jigouxinxi)
    {
        startPage();
        List<Jigouxinxi> list = jigouxinxiService.selectJigouxinxiList(jigouxinxi);
        return getDataTable(list);
    }

    /**
     * 导出机构信息表列表
     */
    @PreAuthorize("@ss.hasPermi('system:jigouxinxi:export')")
    @Log(title = "机构信息表", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Jigouxinxi jigouxinxi)
    {
        List<Jigouxinxi> list = jigouxinxiService.selectJigouxinxiList(jigouxinxi);
        ExcelUtil<Jigouxinxi> util = new ExcelUtil<Jigouxinxi>(Jigouxinxi.class);
        util.exportExcel(response, list, "机构信息表数据");
    }

    /**
     * 获取机构信息表详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:jigouxinxi:query')")
    @GetMapping(value = "/{fullName}")
    public AjaxResult getInfo(@PathVariable("fullName") String fullName)
    {
        return success(jigouxinxiService.selectJigouxinxiByFullName(fullName));
    }

    /**
     * 新增机构信息表
     */
    @PreAuthorize("@ss.hasPermi('system:jigouxinxi:add')")
    @Log(title = "机构信息表", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Jigouxinxi jigouxinxi)
    {
        return toAjax(jigouxinxiService.insertJigouxinxi(jigouxinxi));
    }

    /**
     * 修改机构信息表
     */
    @PreAuthorize("@ss.hasPermi('system:jigouxinxi:edit')")
    @Log(title = "机构信息表", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Jigouxinxi jigouxinxi)
    {
        return toAjax(jigouxinxiService.updateJigouxinxi(jigouxinxi));
    }

    /**
     * 删除机构信息表
     */
    @PreAuthorize("@ss.hasPermi('system:jigouxinxi:remove')")
    @Log(title = "机构信息表", businessType = BusinessType.DELETE)
	@DeleteMapping("/{fullNames}")
    public AjaxResult remove(@PathVariable String[] fullNames)
    {
        return toAjax(jigouxinxiService.deleteJigouxinxiByFullNames(fullNames));
    }
}
